package com.hxy.health.platform.controller;

import com.hxy.health.platform.pojo.Employee;
import com.hxy.health.platform.pojo.Product;
import com.hxy.health.platform.service.EmployeeService;
import com.hxy.health.platform.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class PageController {
    @Autowired
    private ProductService productService;
    @Autowired
    private EmployeeService employeeService;
    /**
     * 跳转到首页
     */
    @RequestMapping("page/index")
    public String indexPage(ModelMap modelMap) {
        List<Product> products = productService.getNewProduct();
        modelMap.addAttribute("products", products);
        return "index";
    }
    /**
     * 跳转到登录或者注册界面
     */
    @RequestMapping("page/loginOrRegister")
    public String loginOrRegisterPage(ModelMap modelMap) {
        modelMap.addAttribute("name","JSON");
        return "loginOrRegister";
    }

    /**
     * 跳转到关于我们页面
     */
    @RequestMapping("page/aboutUs")
    public String aboutUsPage(ModelMap modelMap) {
        List<Employee> employees = employeeService.getAll();
        modelMap.addAttribute("employees", employees);
        return "about";
    }





}
